package com.yeban.javase.review.exercise;

import java.io.*;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/27
 *
 * 字节流复制一张图片 src/com/yeban/javase/day15/cat.jpg，复制到 copy_cat.jpg。
 */
public class FileInputStreamReview {

    public static void main(String[] args) throws FileNotFoundException {
        try(
                FileInputStream fis = new FileInputStream("src/com/yeban/javase/review/images/cat.png");
                FileOutputStream fos = new FileOutputStream("src/com/yeban/javase/review/images/cat_copy1.png");
        )
        {
            byte[] bytes = new byte[1024];
            int len = 0;
            while((len = fis.read(bytes)) != -1) {
                fos.write(bytes, 0, len);
            }
            System.out.println("写出成功！");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
